import org.apache.spark.sql.SparkSession

object aj {

  def main(args: Array[String]): Unit = {
    // 创建 SparkSession
    val spark = SparkSession.builder()
      .appName("Test")
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext

    try {
      val rdd1 = sc.parallelize(List(('a', 1), ('b', 2), ('c', 3)))
      val rdd2 = sc.parallelize(List(('a', 1), ('d', 4), ('e', 5)))
     val left_join = rdd1.leftOuterJoin(rdd2)
      left_join.collect
      left_join.collect().foreach(println)
    } finally {
      // 停止 SparkSession
      spark.stop()
    }
  }
}
